using System.Windows;
using Microsoft.Practices.Composite.Modularity;
using Microsoft.Practices.Composite.UnityExtensions;
using Microsoft.Practices.Unity;
using System;

namespace BlueMarble.Genesis.Shell
{
    public partial class ShellBootstrapper : UnityBootstrapper
    {
        protected override void ConfigureContainer()
        {
            Container.RegisterType<BlueMarble.Genesis.Infrastructure.IShellView, BlueMarble.Genesis.Shell.View>();
            Container.RegisterType<BlueMarble.Genesis.Infrastructure.IShellViewModel, BlueMarble.Genesis.Shell.ViewModel>();
            
            base.ConfigureContainer();
        }

        protected override DependencyObject CreateShell()
        {
            BlueMarble.Genesis.Infrastructure.IShellViewModel viewModel = Container.Resolve<BlueMarble.Genesis.Infrastructure.IShellViewModel>();

            viewModel.View.ShowView();

            return viewModel.View as DependencyObject;
        }

        protected override Microsoft.Practices.Composite.Modularity.IModuleCatalog GetModuleCatalog()
        {
#if !SILVERLIGHT
            return Microsoft.Practices.Composite.Modularity.ModuleCatalog.CreateFromXaml(
                new Uri("BlueMarble.Genesis.Shell;component/Resources/ModuleCatalog.Desktop.xaml", UriKind.Relative));
#else
            return Microsoft.Practices.Composite.Modularity.ModuleCatalog.CreateFromXaml(
                new Uri("BlueMarble.Genesis.Shell;component/Resources/ModuleCatalog.Silverlight.xaml", UriKind.Relative));
#endif
        }

        protected override Microsoft.Practices.Composite.Presentation.Regions.RegionAdapterMappings ConfigureRegionAdapterMappings()
        {
            var mappings = base.ConfigureRegionAdapterMappings();

            return mappings;
        }
    }
}
